<template>
    <div class="">
        <div class="pr10">
                <div class="analyItem pr10">
                    <p class="analyItemTit tx-center">状态</p>
                    <div class="analyItemCon">
                    </div>
                </div>
        </div>
        <div class="thinScrol pr10" v-scrollHeight="84">
                    <router-link tag="div" :to="routerPath('minleve')" class="analyItem anItemBor" active-class="anItemBor-active">
                <p class="analyItemTit tx-center analyShallowGreen">3级</p>
                <div class="analyItemCon">
                    <p class="col-md-2">
                        <span class="cLightGray pr8">团队</span>
                    </p>
                    <p class="col-md-2">
                        <span class="cLightGray pr8">案例</span>
                    </p>
                    <p class="col-md-2">
                        <span class="cLightGray pr8">保证金</span>
                    </p>
                    <p class="col-md-2">
                        <span class="cLightGray pr8">专业考核</span>
                    </p>
                    <p class="col-md-2">
                        <span class="cLightGray pr8">资料</span>
                    </p>
                </div>
            </router-link>
            <router-link exact v-for="(item,index) in upGradeList" :key="index" tag="div" :to="{path:routerPath('detail'), query:{upGrade:upGradeList[index]}}" class="analyItem anItemBor" active-class="anItemBor-active">
             <p class="analyItemTit tx-center analyLightGreen" v-if="Number(item.leLevel) === Number(nextLevel)">{{item.leLevel}} 级</p>
             <p :class="['analyItemTit', 'tx-center', item.leLevel<nextLevel ? 'analyShallowGreen' : '']" v-else>{{item.leLevel}} 级</p>
            <!--     <p class="analyItemTit tx-center">{{item.leLevel+'级'}}</p> -->
                <div class="analyItemCon" v-if="item.leLevel<=6">
                    <p class="col-md-12">
                        <span class="tx-center">标准</span>
                        <span class="rz-num">{{item.leLevel&lt;6?12:10}}</span>
                    </p>
                     <p class="col-md-8">
                    <span class="cLightGray pr8">规则</span>
                    <span> 有效竣工额、 订单完成率、 好评</span>
                </p>
                 <p class="col-md-4">
                    <span class="cLightGray pr8">时间</span>
                    <span>{{item.leLevel|levelPi(levelDate)}}</span>
                </p>
                </div>
                <div class="analyItemCon" v-else>
                    <p class="col-md-12">
                        <span class="tx-center">标准</span>
                        <span class="rz-num">{{item.leLevel&lt;6?12:10}}</span>
                    </p>
                     <p class="col-md-8">
                    <span class="cLightGray pr8">规则</span>
                      <span>培训、证书、成就、产值比、 好评</span>
                </p>
                 <p class="col-md-4">
                    <span class="cLightGray pr8">时间</span>
                    <span>{{item.leLevel|levelPi(levelDate)}}</span>
                </p>
                </div>
            </router-link>
        </div>
        <div class="pr10">
            <div class="analyItem">
                <p class="analyItemTit tx-center">综合</p>
                <div class="analyItemCon">
                    <p class="col-md-6">
                        <span class="cLightGray pr8">共有</span>
                        <span>{{upGradeList.length}}项</span>
                    </p>
                    <p class="col-md-6">
                        <span class="cLightGray pr8">完成</span>
                        <span></span>
                    </p>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import {
    mapGetters
} from 'vuex'
import {
    getLeve, getLevelDate
} from '../Resources/Api'
export default {
    data () {
        return {
            upGradeList: [],
            upGradeList1: [],
            currentLevel: 0,
            nextLevel: 0, // 级别
            levelDate: [],
            le: 0
        }
    },
    created () {
        this.currentLevel = this.leftInfo.user_level
        this.nextLevel = this.leftInfo.user_level !== '' && this.leftInfo.user_level >= 0 ? Number(this.leftInfo.user_level) + 1 : ' '
        this.getLeveDetail()
        this.LevelDate()
    },
    methods: {


        // isNumber (val) {
        //     var regPos = /^\d+(\.\d+)?$/ // 非负浮点数
        //     var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/ // 负浮点数
        //     if (regPos.test(val) || regNeg.test(val)) {
        //         return true
        //     } else {
        //         return false
        //     }
        // },
        // pipeiLevel (levelDate) {
        //     this.levelDate.forEach((item, index) => {
        //         let level = item.content
        //         let bol = this.isNumber(level)
        //         if (bol === false) {
        //             this.le = level.substring(0, 1)
        //         } else {

        //         }
        //     })
        // },

        LevelDate () {
            let _this = this
            _this.levelDate = []
            getLevelDate({
                uid: this.leftInfo.uid
            }).then(result => {
                if (result.data.StatusCode === 0) {
                    _this.levelDate = result.data.Body
                }
            }).catch(err => {
                console.log(err)
            })
        },
        getLeveDetail () {
            let _this = this
            _this.upGradeList = []
            _this.upGradeList1 = []
            getLeve().then(results => {
                _this.upGradeList1 = results.data.Body
                _this.upGradeList1.forEach(element => {
                    if (element.leLevel <= 12) {
                        _this.upGradeList.push(element)
                    }
                })
            }).catch(error => {
                console.log(error)
            })
        },

        // 路由跳转路径拼接
        routerPath (path) {
            return this.$route.matched[1].path + '/' + path
        },
        // 直接进行路由跳转路径
        routerPush (path) {
            this.$router.push(this.$route.matched[1].path + '/' + path)
        }
    },
    computed: {
        ...mapGetters(['leftInfo'])
    },
    updated: function () {
    },
    filters: {
        levelPi (level, data) {
            let currentLevel = ''
            // let data = []
            if (data !== undefined && data.length > 0) {
                data.forEach((item, index) => {
                    if (Number(level) === Number(item.level)) {
                        currentLevel = item.leveldate.substring(0, 10)
                    } else {
                        currentLevel = '--'
                    }
                })
                return currentLevel
            } else {
                return '--'
            }
        }
    },
    watch: {
        leftInfo () {
            this.getLeveDetail()
            this.LevelDate()
            this.nextLevel = this.leftInfo.user_level !== '' && this.leftInfo.user_level >= 0 ? Number(this.leftInfo.user_level) + 1 : ' '
        }
    }
}
</script>
